﻿using BLL;
using Model;
using System;
using System.Web.UI;

namespace Thksoft.BusinessExpansion.Business
{
    public partial class BussTran : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            if (Request["trancId"] != null && Request["trancId"].ToString() != "")
            {
                string trid = Request.QueryString["trancId"].ToString();
                Lc_Transaction model = new Lc_TransactionBLL().GetInfoById(trid);
                if (model != null)
                {
                    Session.Remove("Vbusiness");
                    Session["Vbusiness"] = model.N_business_id.ToString();

                    Session.Remove("tranid");
                    Session["tranid"] = trid;

                    string proid = model.N_PROCESS_ID.ToString();

                    Lc_Queue qModel = new Lc_QueueBLL().GetInfoById(model.N_QUEUE_ID.ToString());

                    if (qModel == null)
                    {
                        return;
                    }

                    string[] mk = qModel.C_QUEUE_BLOCK.Split(',');

                    for (int i = 0; i < mk.Length; i++)
                    {
                        if (mk[i] != "")
                        {
                            Lc_Block bModel = new Lc_BlockBLL().GetEntity(decimal.Parse(mk[i]));

                            if (bModel != null)
                            {
                                if (i == 0)
                                {
                                    Tab1.Visible = true;
                                    Tab1.HeaderText = bModel.C_BLOCK_NAME;
                                    Control trol = Page.LoadControl("../../UserCotrols/" + bModel.C_BLOCK_DEPATH.Trim());
                                    PlaceHolder1.Controls.Add(trol);  //加载申请明细信息控件
                                }
                                else if (i == 1)
                                {
                                    Tab2.Visible = true;
                                    Tab2.HeaderText = bModel.C_BLOCK_NAME;
                                    Control trol = Page.LoadControl("../../UserCotrols/" + bModel.C_BLOCK_DEPATH.Trim());
                                    PlaceHolder2.Controls.Add(trol);  //加载申请明细信息控件
                                }
                                else if (i == 2)
                                {
                                    Tab3.Visible = true;
                                    Tab3.HeaderText = bModel.C_BLOCK_NAME;
                                    Control trol = Page.LoadControl("../../UserCotrols/" + bModel.C_BLOCK_DEPATH.Trim());
                                    PlaceHolder3.Controls.Add(trol);  //加载申请明细信息控件
                                }
                                else if (i == 3)
                                {
                                    Tab4.Visible = true;
                                    Tab4.HeaderText = bModel.C_BLOCK_NAME;
                                    Control trol = Page.LoadControl("../../UserCotrols/" + bModel.C_BLOCK_DEPATH.Trim());
                                    PlaceHolder4.Controls.Add(trol);  //加载申请明细信息控件
                                }
                            }
                        }
                    }

                    #region MyRegion

                    /*
                    switch (proid)
                    {
                        case "45":
                            {
                                #region 周长期资金申请

                                Control trol = Page.LoadControl("../../UserCotrols/ApplyInfoControl.ascx");
                                PlaceHolder1.Controls.Add(trol);  //加载申请明细信息控件

                                #endregion 周长期资金申请
                            }
                            break;

                        case "49":
                            {
                                #region 紧急资金申请

                                Control trolup = Page.LoadControl("../../UserCotrols/UrgentDetail.ascx");
                                PlaceHolder1.Controls.Add(trolup);

                                #endregion 紧急资金申请
                            }
                            break;

                        case "50":
                            {
                                #region 周资金计划申请

                                Control trol = Page.LoadControl("../../UserCotrols/TheirFundsControl.ascx");
                                PlaceHolder1.Controls.Add(trol);  //加载申请明细信息控件

                                #endregion 周资金计划申请
                            }
                            break;

                        case "51":
                            {
                                #region 月资金计划

                                //Page.LoadControl(typeof(CtrlMonthFunds), null);
                                Control trol = Page.LoadControl("../../UserCotrols/CtrlMonthFunds.ascx");
                                PlaceHolder1.Controls.Add(trol);

                                #endregion 月资金计划
                            }
                            break;

                        case "121":
                            {
                                 #region 年资金计划

                                //Page.LoadControl(typeof(CtrlMonthFunds), null);
                                //Control trol = Page.LoadControl("../../UserCotrols/CtrlYearFunds.ascx");
                                //PlaceHolder1.Controls.Add(trol);

                                #endregion 年资金计划
                            }
                            break;

                        default:
                            break;
                    }*/

                    //Tab1.Visible = true;
                    //Tab1.HeaderText = "业务信息";

                    #endregion MyRegion

                    Control trolUpload = Page.LoadControl("../../UserCotrols/UploadFile.ascx");
                    phd_UploadFile.Controls.Add(trolUpload);  //加载上传附件控件

                    Control trolTran = Page.LoadControl("../../UserCotrols/TranturnInfo.ascx");
                    phd_TranInfo.Controls.Add(trolTran);//加载办理流水
                    if (model.N_QUEUE_ID == 211 || model.N_QUEUE_ID == 213 || model.N_QUEUE_ID == 215)
                    {
                    }
                    else
                    {
                        Control nControl = Page.LoadControl("../../UserCotrols/BinsinessDo.ascx");
                        Buniss.Controls.Add(nControl);
                    }
                }
            }
            //}
        }

        //绑定附件信息
        private void bindfilse(string biss)
        {
            //Session.Remove("Vbusiness");
            //Session["Vbusiness"] = biss;
            //Control trolUpload = Page.LoadControl("../../UserCotrols/UploadFile.ascx");
            //upfilse.Controls.Add(trolUpload);
        }

        //绑定附件信息
        private void bindTran(string trid)
        {
            //  Control nControl = Page.LoadControl("BusInformation.aspx");
            // Buniss.Controls.Add(nControl);
        }

        ///// <summary>
        ///// 转换条件绑定lable值
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        protected void radbllx_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
    }
}